home *** CD-ROM | disk | FTP | other *** search
- Path: anvil.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: New (but motivated) C user looking for help . . .
- Date: 28 Feb 1996 12:54:46 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4h2femINNrgi@anvil.ugrad.cs.ubc.ca>
- References: <4h10do$mqh@maureen.teleport.com> <4h1s9f$8nf@pyrrhus-f.hrz.tu-chemnitz.de>
- NNTP-Posting-Host: anvil.ugrad.cs.ubc.ca
-
- In article <4h1s9f$8nf@pyrrhus-f.hrz.tu-chemnitz.de>,
- Hans Steffani <hfst@hrz.tu-chemnitz.de> wrote:
- >Input the adress as string.
- >Break it to substrings using "." as delimiter.
- >Convert the substrings without the "." to integer.
- >Use & and | to do or and and conjunction.
-
- If you are doing internet programming with Berkeley sockets, functions that do
- this kind of thing are provided for you. Standard C functions they are not, but
- they do exist in environments where inet meets C.
-
- hp-ux$ man inet
-
- net(3N) inet(3N)
-
- NAME
- inet_addr(), inet_network(), inet_ntoa(), inet_makeaddr(),
- inet_lnaof(), inet_netof() - Internet address manipulation routines
-
- SYNOPSIS
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <arpa/inet.h>
-
- unsigned long inet_addr(const char *cp);
-
- unsigned long inet_network(const char *cp);
-
- char *inet_ntoa(struct in_addr in);
-
- struct in_addr inet_makeaddr(int net, int lna);
-
- int inet_lnaof(struct in_addr in);
-
- int inet_netof(struct in_addr in);
-
- DESCRIPTION
- inet_addr() Interpret character strings representing numbers
- inet_network() expressed in the Internet standard ``dot''
- notation.
-
- inet_addr() returns numbers suitable for use as
- Internet addresses.
-
- inet_network() returns numbers suitable for use
- as Internet network numbers>
-
- Return values can be assigned to a struct
- in_addr (defined in /usr/include/netinet/in.h)
- by using a technique similar to the following:
-
- struct in_addr addr;
- char *cp;
-
- addr.s_addr = inet_addr(cp);
-
- By the way, the above sentence is not correct. The unsigned long result of
- inet_addr() is _not_ being incorrectly assigned to a struct, but to an unsigned
- long element of the struct.
- --
-
-